import React, { Component } from 'react'
import NavBar from './component/NavBar'
import TabBar from './component/TabBar'
import RouterComp from './router'
import { withRouter } from 'react-router-dom'
import routes from './router/routerConfig'

// withRouter 高阶组件
class App extends Component {
  render() {
    const {location:{pathname}} = this.props
    const routeItem = routes.filter(item =>item.path === pathname)[0] 
    const { type, title } = routeItem ? routeItem : {type: '', title: ''}
    return (
      <div className='app'>
        <NavBar title={title}/>
        <RouterComp/>
        {type && <TabBar/>}
      </div>
    )
  }
}
export default withRouter(App)
